/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
// 1. 二叉搜索树中序遍历从小到大
func kthSmallest(root *TreeNode, k int) int {
	res = nil
	inorder(root)
	return res[k-1]
}

var res []int

func inorder(root *TreeNode) {
	if root == nil {
		return
	}
	inorder(root.Left)
	res = append(res, root.Val)
	inorder(root.Right)
}